#!/usr/bin/python
# -*- coding: utf-8 -*-
# author: yoshiii.yoshiii@googlemail.com
# you found this code on http://yoshiii-box.googlecode.com/svn/ 
#
import sys

# define conversion function which will be executed on each line
#convert = int
convert = float

class histogramm:
    def __init__(self):
	self._values_ = []
    def __str__(self):
	return str(self.getHist())
    def add(self, value):
	self._values_.append(value)
    def getHist(self):
	from itertools import groupby
	return [(k, len(list(g))) for k, g in groupby(sorted(self._values_))]
    def getValues(self):
	return self._values_

def calc_stats(input=sys.stdin, output=sys.stdout, error=sys.stderr):
    sum, cnt = 0, 0
    hist = histogramm()
    for line in input.readlines():
	for item in line.split():
	    item = item.strip()
	    try:
		num = convert(item)
		sum += num
		cnt += 1
		hist.add(num)
	    except ValueError, e:
    #	    print >> error, "ValueError", e
		pass
    print >> output, "items:", cnt
    print >> output, "sum:  ", sum
    print >> output, "avg:  ", float(sum)/cnt
#    print >> output, "hist: ", hist

def main():
    calc_stats()

if __name__ == '__main__':
    main()
